{extend name="../../../view/public/base" /}
{block name="css"}
<style>

    .select-test{position: absolute;max-height: 500px;height: 350px;overflow: auto;width: 100%;z-index: 123;display: none;border:1px solid silver;top: 42px;}
    .layui-show{display: block!important;}
    .layui-form-pane .layui-form-label {
        font-size: 10px;
    }
    .layui-elip, .layui-form-checkbox span, .layui-form-pane .layui-form-label {
        text-overflow:clip;
        white-space: nowrap;
    }
</style>
{/block}
{block name="body"}
<form class="layui-form layui-form-pane" id="form">


    <blockquote class="layui-elem-quote"><h3><i class="layui-icon">&#xe611;</i>&nbsp&nbsp&nbsp
        <span style="color: red;">配置展示规则和配置使用方法请阅读开发文档</span>
    </h3></blockquote>

    <input type="hidden" id="id" name="id" value="{$entity.id? $entity.id : 0}"/>
    <div class="layui-tab layui-tab-card" lay-filter="docDemoTabBrief">
        <ul class="layui-tab-title"  >
            <li class="layui-this">普通文本框</li>
            <li>多行文本域</li>
            <li>富文本域</li>
            <li>单选框</li>
            <li>复选框</li>
            <li>下拉框</li>
            <li>文件上传</li>
        </ul>
        <div class="layui-tab-content" style="height: 100px;">
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red; font-size: 20px">*</span>配置分类：</label>
                <div class="layui-input-block" >
                    <select name="tab_id" id="tab_id" lay-verify="required" >
                        <option value="">请选择</option>
                        {if !empty($entity.tab_id)}
                        {volist name="tab" id="vo"}
                        {eq name="vo.id" value="$entity.tab_id"}
                        <option value="{$vo.id}" disabled selected="">{$vo.title}</option>
                        {else/}
                        <option value="{$vo.id}" disabled >{$vo.title}</option>
                        {/eq}
                        {/volist}
                        {else/}
                        {volist name="tab" id="vo"}
                        {eq name="vo.id" value="$tab_id"}
                        <option value="{$vo.id}" selected="">{$vo.title}</option>
                        {else/}
                        <option value="{$vo.id}">{$vo.title}</option>
                        {/eq}
                        {/volist}
                        {/if}


                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span style = "color:red;">*</span>配置名称：</label>
                <div class="layui-input-block" >
                    <input  type="text" name="info" lay-verify="info"
                            autocomplete="off" placeholder="请输入配置名称" class="layui-input"
                            value="{$entity.info? $entity.info : null}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span style = "color:red;">*</span>配置字段：</label>
                <div class="layui-input-block" >
                    <input  type="text" name="config_name" lay-verify="config_name"
                            autocomplete="off" placeholder="例：site_url" class="layui-input"
                            onkeyup="this.value=this.value.replace(/[^\w_]/g,'');"
                            value="{$entity.config_name? $entity.config_name : null}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">配置提示：</label>
                <div class="layui-input-block" >
                    <input  type="text" name="desc" lay-verify="desc"
                            autocomplete="off" placeholder="请输入配置提示" class="layui-input"
                            value="{$entity.desc? $entity.desc : null}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">权重：</label>
                <div class="layui-input-block" >
                    <input  type="number" name="sort" lay-verify="sort"
                            autocomplete="off" placeholder="请输入权重,影响显示顺序" class="layui-input"
                            value="{$entity.sort? $entity.sort : null}">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label"><span style = "color:red;">*</span>状态：</label>
                <div class="layui-input-block">
                    {if !empty($entity.status)}

                    <input type="radio" name="status"  value="1"  title="隐藏"  {$entity.status==1 ? 'checked':'' } >
                    <input type="radio" name="status"  value="0"  title="显示"  {$entity.status==0 ?  'checked':'' }>
                    {else/}
                    <input type="radio" name="status"  value="1"  title="隐藏"  >
                    <input type="radio" name="status"  value="0"  title="显示" checked>

                    {/if}
                </div>
            </div>

            <div class="layui-form-item" >
                <label class="layui-form-label">懒插入：</label>
                <div class="layui-input-block">
                    {if !empty($entity.lazy)}

                    <input type="radio" name="lazy"  value="1"  title="是"  disabled {$entity.lazy==1 ? 'checked':'' } >
                    <input type="radio" name="lazy"  value="2"  title="否" disabled  {$entity.lazy==2 ?  'checked':'' } >
                    {else/}
                    <input type="radio" name="lazy"  value="1"  title="是"  checked>
                    <input type="radio" name="lazy"  value="2"  title="否" >

                    {/if}
                    <span style = "color:red;">(设置懒插入只有在租户设置配置值时才会插入配置数据)</span>
                </div>
            </div>

            <!--<div class="layui-form-item">-->
            <!--<label class="layui-form-label">disabled属性：</label>-->
            <!--<div class="layui-input-block">-->
            <!--{if !empty($entity.disabled)}-->

            <!--<input type="radio" name="disabled"  value="1"  title="是"  {$entity.disabled==1 ? 'checked':'' } >-->
            <!--<input type="radio" name="disabled"  value="2"  title="否"  {$entity.disabled==2 ?  'checked':'' }>-->
            <!--{else/}-->
            <!--<input type="radio" name="disabled"  value="1"  title="是"  >-->
            <!--<input type="radio" name="disabled"  value="2"  title="否" checked>-->

            <!--{/if}-->
            <!--<span style = "color:red;">(上传无效)</span>-->
            <!--</div>-->
            <!--</div>-->

            <!--<input type="hidden"  name="type" value="{$entity.type? $entity.type : 'upload'}"/>-->
            <!--<div class="layui-form-item">-->
            <!--<label class="layui-form-label"><span style = "color:red;">*</span>配置权限：</label>-->
            <!--<div class="layui-input-block">-->
            <!--{if !empty($entity.scopes)}-->
            <!--<input type="radio" name="scopes"  value="common"  title="平台"  {$entity.scopes=='common' ? 'checked':'' } >-->
            <!--<input type="radio" name="scopes"  value="admin"  title="总后台"  {$entity.scopes=='admin' ?  'checked':'' }>-->
            <!--<input type="radio" name="scopes"  value="member"  title="租户"  {$entity.scopes=='member' ?  'checked':'' }>-->
            <!--{else/}-->
            <!--<input type="radio" name="scopes"  value="common"  title="平台" checked >-->
            <!--<input type="radio" name="scopes"  value="admin"  title="总后台">-->
            <!--<input type="radio" name="scopes"  value="member"  title="租户">-->
            <!--{/if}-->
            <!--</div>-->
            <!--</div>-->



            <div class="layui-tab-item layui-show">
                <!--普通文本框-->
                <div class="layui-form-item">
                    <!--<input type="hidden"  name="type" value="{$entity.type? $entity.type : 'text'}"/>-->
                    <label class="layui-form-label"><span style="color: red; font-size: 20px">*</span>文本类型：</label>
                    <div class="layui-input-block" >
                        <select name="input_type" id="input_type" lay-verify="required" >
                            {if !empty($entity.input_type)}
                            <option value="text"  {$entity.input_type=='text' ? 'selected=""':'' } >文本框</option>
                            <option value="number"  {$entity.input_type=='number' ? 'selected=""':'' } >数字</option>
                            <option value="float"  {$entity.input_type=='float' ? 'selected=""':'' } >浮点数</option>
                            <option value="timestamp"  {$entity.input_type=='timestamp' ? 'selected=""':'' } >日期(时间戳)</option>
                            <option value="color"  {$entity.input_type=='color' ? 'selected=""':'' } >颜色</option>
                            {else/}
                            <option value="text"  selected="" >文本框</option>
                            <option value="number"   >数字</option>
                            <option value="float"    >浮点数</option>
                            <option value="timestamp"   >日期(时间戳)</option>
                            <option value="color"   >颜色</option>
                            {/if}


                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;"></span>验证规则：</label>
                    <div class="layui-input-block" >
                        <input  type="text" name="rule" lay-verify="rule"
                                autocomplete="off" placeholder="使用thinkphp框架的验证器，多个规则“|”竖线隔开，例：number|between:1,120 或 require|max:25" class="layui-input"
                                value="{$entity.rule? $entity.rule : null}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;"></span>验证提示：</label>
                    <div class="layui-input-block" >
                        <input  type="text" name="message" lay-verify="message"
                                autocomplete="off" placeholder="使用thinkphp框架的验证器，多个提示“|”竖线隔开，例：name.require=>名称必须|age.between=>年龄只能在1-120之间" class="layui-input"
                                value="{$entity.message? $entity.message : null}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;">*</span>默认值：</label>
                    <div class="layui-input-block" >
                        <input  type="text" name="value" lay-verify="value"
                                autocomplete="off" placeholder="请输入默认值" class="layui-input"
                                value="{$entity.value|default=''}">
                    </div>
                </div>

                <!--<div class="layui-form-item">-->
                <!--<label class="layui-form-label"><span style = "color:red;">*</span>类型：</label>-->
                <!--<div class="layui-input-block">-->
                <!--{if !empty($entity.type)}-->
                <!--<input type="radio" name="type"  value="1"  title="系统配置"  {$entity.type==1 ? 'checked':'' } >-->
                <!--<input type="radio" name="type"  value="2"  title="插件配置"  {$entity.type==2 ?  'checked':'' }>-->
                <!--<input type="radio" name="type"  value="3"  title="应用配置"  {$entity.type==3 ?  'checked':'' }>-->
                <!--<input type="radio" name="type"  value="4"  title="其他配置"  {$entity.type==4 ?  'checked':'' }>-->
                <!--{else/}-->
                <!--<input type="radio" name="type"  value="1"  title="系统配置" checked >-->
                <!--<input type="radio" name="type"  value="2"  title="插件配置">-->
                <!--<input type="radio" name="type"  value="3"  title="应用配置">-->
                <!--<input type="radio" name="type"  value="4"  title="其他配置">-->
                <!--{/if}-->
                <!--</div>-->
                <!--</div>-->

                <!--<div class="layui-form-item">-->
                <!--<div class="layui-inline">-->
                <!--<label class="layui-form-label"><span style="color: red; font-size: 20px"></span>选择图标：</label>-->
                <!--<div class="layui-input-inline">-->
                <!--<input  type="text" name="icon" id="icon" lay-verify="icon"-->
                <!--autocomplete="off"  placeholder="单机图标按钮选择图标" class="layui-input"-->
                <!--value="{$entity.icon? $entity.icon : null} " >-->
                <!--</div>-->
                <!--</div>-->
                <!--<div class="layui-inline">-->
                <!--<div class="layui-input-inline">-->
                <!--<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="getNum()">选择图标</button>-->

                <!--</div>-->

                <!--</div>-->
                <!--</div>-->




            </div>
            <div class="layui-tab-item">

                <!--多行文本域-->
                <!--<input type="hidden"  name="type" value="{$entity.type? $entity.type : 'textarea'}"/>-->
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;">*</span>宽度(%)：</label>
                    <div class="layui-input-block" >
                        <input  type="number" name="width" lay-verify="width"
                                autocomplete="off" placeholder="请输入多行文本框的宽度（%）" class="layui-input"
                                value="{$entity.width? $entity.width : 100}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;">*</span>高度(%)：</label>
                    <div class="layui-input-block" >
                        <input  type="number" name="high" lay-verify="high"
                                autocomplete="off" placeholder="请输入多行文本框的高度（%）" class="layui-input"
                                value="{$entity.high? $entity.high : 100}">
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label"><span style="color: red; font-size: 20px">*</span>默认值：</label>
                    <div class="layui-input-block">
                      <textarea placeholder="请输入默认值" class="layui-textarea"
                                lay-verify="value" id ='mtext'>{$entity.value|default=''}</textarea>
                        <input type="hidden" name="value" value="{$entity.value|default=''}"/>
                    </div>
                </div>

            </div>
            <div class="layui-tab-item">

                <!--富文本域-->
                <!--<input type="hidden"  name="type" value="{$entity.type? $entity.type : 'r_textarea'}"/>-->
                <!--<div class="layui-form-item">-->
                <!--<label class="layui-form-label"><span style = "color:red;">*</span>宽度：</label>-->
                <!--<div class="layui-input-block" >-->
                <!--<input  type="number" name="width" lay-verify="width"-->
                <!--autocomplete="off" placeholder="请输入多行文本框的宽度（%）" class="layui-input"-->
                <!--value="{$entity.width? $entity.width : null}">-->
                <!--</div>-->
                <!--</div>-->

                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;">*</span>高度(px)：</label>
                    <div class="layui-input-block" >
                        <input  type="number" name="high" lay-verify="high"
                                autocomplete="off" placeholder="请输入富文本域的高度（px）" class="layui-input"
                                value="{$entity.high? $entity.high : 200}">
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label"><span style="color: red; font-size: 20px">*</span>默认值：</label>
                    <div class="layui-input-block">
                      <textarea placeholder="请输入默认值" class="layui-textarea"
                                lay-verify="value" id ='rtext'>{$entity.value|default=''}</textarea>
                        <input type="hidden" name="value" value="{$entity.value|default=''}"/>
                    </div>
                </div>

            </div>
            <div class="layui-tab-item">
                <!--单选框-->
                <!--<input type="hidden"  name="type" value="{$entity.type? $entity.type : 'radio'}"/>-->
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label"><span style="color: red; font-size: 20px">*</span>选择框参数：</label>
                    <div class="layui-input-block">
                      <textarea placeholder="每个选项独占一行,参数方式例如:
                      男=>1
                      女=>2
                      蒙娜丽莎=>3" class="layui-textarea"
                                lay-verify="value" id ='parameter'>{$entity.parameter? $entity.parameter : null}</textarea>
                        <input type="hidden" name="parameter" value="{$entity.parameter? $entity.parameter : null}"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;">*</span>默认值：</label>
                    <div class="layui-input-block" >
                        <input  type="text" name="radio_value" lay-verify="value"
                                autocomplete="off" placeholder="请输入默认值" class="layui-input"
                                onkeyup="this.value=this.value.replace(/[, ]/g,'')"
                                value="{$entity.value|default=''}">
                    </div>
                </div>


            </div>
            <div class="layui-tab-item">
                <!--复选框-->
                <!--<input type="hidden"  name="type" value="{$entity.type? $entity.type : 'checkbox'}"/>-->
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label"><span style="color: red; font-size: 20px">*</span>选择框参数：</label>
                    <div class="layui-input-block">
                      <textarea placeholder="每个选项独占一行,参数方式例如:
                      男=>1
                      女=>2
                      蒙娜丽莎=>3" class="layui-textarea"
                                lay-verify="value" id ='mparameter'>{$entity.parameter? $entity.parameter : null}</textarea>
                        <input type="hidden" name="parameter" value="{$entity.parameter? $entity.parameter : null}"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;">*</span>默认值：</label>
                    <div class="layui-input-block" >
                        <input  type="text" name="checkbox_value" lay-verify="value"
                                autocomplete="off" placeholder="请输入默认值,复选框多值逗号“ ， ”隔开" class="layui-input"
                                value="{$entity.value|default=''}">
                    </div>
                </div>


            </div>
            <div class="layui-tab-item">
                <!--下拉框-->
                <!--<input type="hidden"  name="type" value="{$entity.type? $entity.type : 'select'}"/>-->
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label"><span style="color: red; font-size: 20px">*</span>下拉框参数：</label>
                    <div class="layui-input-block">
                      <textarea placeholder="每个选项独占一行,参数方式例如:
                      男=>1
                      女=>2
                      蒙娜丽莎=>3" class="layui-textarea"
                                lay-verify="value" id ='oparameter'>{$entity.parameter? $entity.parameter : null}</textarea>
                        <input type="hidden" name="parameter" value="{$entity.parameter? $entity.parameter : null}"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;">*</span>默认值：</label>
                    <div class="layui-input-block" >
                        <input  type="text" name="select_value" lay-verify="value"
                                autocomplete="off" placeholder="请输入默认值" class="layui-input"
                                onkeyup="this.value=this.value.replace(/[, ]/g,'')"
                                value="{$entity.value|default=''}">
                    </div>
                </div>

            </div>
            <div class="layui-tab-item">
                <!--文件上传未实现-->
                <!--<input type="hidden"  name="type" value="{$entity.type? $entity.type : 'upload'}"/>-->
                <div class="layui-form-item">
                    <label class="layui-form-label"><span style = "color:red;">*</span>上传类型：</label>
                    <div class="layui-input-block">
                        {if !empty($entity.upload_type)}
                        <input type="radio" name="upload_type"  value="1"  title="单图"  {$entity.upload_type==1 ? 'checked':'' } >
                        <input type="radio" name="upload_type"  value="2"  title="多图"  {$entity.upload_type==2 ?  'checked':'' }>
                        <input type="radio" name="upload_type"  value="3"  title="文件"  {$entity.upload_type==3 ?  'checked':'' }>
                        {else/}
                        <input type="radio" name="upload_type"  value="1"  title="单图" checked >
                        <input type="radio" name="upload_type"  value="2"  title="多图">
                        <input type="radio" name="upload_type"  value="3"  title="文件">
                        {/if}
                    </div>
                </div>

            </div>




        </div>
    </div>






</form>

{/block}

{block name="js"}

<script>

    var table;
    var laydate;
    var util;
    var	$;
    var result = "";
    var form;
    var auth_status = '';
    var dtree;
    var layedit;
    var layedit_index;
    var tab_type='text';
    layui.use(['form', 'table','util','laydate','layer','element','layedit'],function() {
        $ = layui.jquery;
        var util = layui.util,layer = layui.layer ,element = layui.element;
        table = layui.table;
        form = layui.form;
        laydate = layui.laydate;
        layedit = layui.layedit;

        layedit.set({
            uploadImage: {
                url: "{:Url('/manage/publicCommon/uploadEditor')}?layui=1" //接口url
                ,type: 'post' //默认post
            }
        });

        layedit_index = layedit.build('rtext'); //建立编辑器

        $(function(){
            //判断如果存在这个分类则使用它
            var i  =getIndex("{$entity.type? $entity.type : 'text'}");

            $(".layui-tab-title li").removeClass("layui-this");
            $(".layui-tab-content .layui-tab-item").removeClass("layui-show");
            $(".layui-tab-title li:eq("+i+")").addClass("layui-this");
            $(".layui-tab-content .layui-tab-item:eq("+i+")").addClass("layui-show");
            tab_type = getType(i);
        });

        //触发tab事件
        element.on('tab(docDemoTabBrief)', function(elem){
            // location.hash = 'test='+ $(this).attr('lay-id');
            //TODO 将筛选条件全部清空
            document.getElementById("form").reset();
            console.log(layedit.getContent(layedit_index));
            //清除富文本
            $('#LAY_layedit_1').contents().find('body').html('');
            //tab切换下标事件
            tab_type = getType(elem.index);
            console.log(tab_type)
        });


    })

    //选择图标
    function getNum(){

        layer.open({
            type: 2,
            title: '图标列表',
            shade: 0.8,
            //closeBtn: 0, //不显示关闭按钮
            shade: [0],
            shadeClose: true,//单机空白处消失
            maxmin: true,
            //anim: 4, //动画类型
            area: ['40%','90%'],
            content:"{:Url('public_common/icon')}",
            btn: ['选择图标'],
            yes: function(index, layero){

                var nodeName = window["layui-layer-iframe" + index];//父页面引用
                var icon = nodeName.getIcon();
                if(icon!=false){
                    $('#icon').val(icon);
                    layer.close(index);
                    //处理重复提交
                }





            }
        });
    }
    function getId(){
        return $('#id').val();
    }

    function getSaveData(){
        var tab_id =  $("select[name='tab_id']").val();//配置分类id

        var info = $("input[name='info']").val();//配置名称
        var config_name = $("input[name='config_name']").val();//字段名称
        // var desc = $("input[name='desc']").val();//配置简介
        var sort = $("input[name='sort']").val();//排序
        var status = $("input[name='status']:checked").val();//是否隐藏
        //console.log(tab_id)
        if(tab_id == ''){
            layer.msg("请选择配置分类", {
                icon : 2,
                time : 1500
            });
            return false;
        }

        if(info == ''){
            layer.msg("请填写配置名称", {
                icon : 2,
                time : 1500
            });
            return false;
        }

        if(config_name == ''){
            layer.msg("请填写字段名称", {
                icon : 2,
                time : 1500
            });
            return false;
        }
        // if(desc == ''){
        //     layer.msg("请填写配置提示", {
        //         icon : 2,
        //         time : 1500
        //     });
        //     return false;
        // }
        if(status == ''){
            layer.msg("请填写是否隐藏", {
                icon : 2,
                time : 1500
            });
            return false;
        }

        switch(tab_type) {
            case 'text':
                var input_type =  $("select[name='input_type']").val();//配置分类id
                var value = $("input[name='value']").val();//排序

                //如果是数字，只能数整数
                if(input_type=='number'||input_type=='timestamp'){
                    //正则匹配
                    var rag=/^[0-9]*$/;
                    if(!rag.test(value)){
                        layer.msg("数字和时间戳类型的默认值请填写整数", {
                            icon : 2,
                            time : 1500
                        });
                        return false;
                    }


                }

                //如果是浮点，只能输整数和小数
                if(input_type=='float'){
                    //正则匹配
                    var rsag=/^[1-9]\d*.\d*|0.\d*[1-9]\d*$/;
                    if(!rsag.test(value)){
                        layer.msg("浮点数类型请填写小数", {
                            icon : 2,
                            time : 1500
                        });
                        return false;
                    }

                }

                if(value == ''){
                    layer.msg("请填写默认值", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                if(input_type == ''){
                    layer.msg("请选择文本类型", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }

                return $('#form').serialize()+'&value='+value+'&type='+tab_type;
                break;
            case 'textarea':
                var mtext  = $("#mtext").val();//排序
                console.log(mtext)
                if(mtext == ''){
                    layer.msg("请填写默认值", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                return $('#form').serialize()+'&value='+mtext+'&type='+tab_type;
                break;
            case 'r_textarea':
                var value = layedit.getContent(layedit_index);//排序

                if(value == ''){
                    layer.msg("请填写默认值", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                console.log(value);
                return $('#form').serialize()+'&value='+r_text_encode(value)+'&type='+tab_type;
                break;
            case 'radio':
                var value = $("input[name='radio_value']").val();//排序
                var parameter  = $("#parameter").val();//排序
                console.log(value)
                if(parameter.indexOf("=>")==-1){
                    layer.msg("请填写合法选项参数", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                var split = parameter.split("=>");
                if(split.length<=2&&(split[1]==''||split[0]=='')){
                    layer.msg("请填写合法选项参数", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }


                if(value == ''){
                    layer.msg("请填写默认值", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                if(parameter == ''){
                    layer.msg("请填写选择框参数", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                return $('#form').serialize()+'&value='+value+'&type='+tab_type+'&parameter='+parameter;
                break;
            case 'checkbox':
                var value = $("input[name='checkbox_value']").val();//排序
                var parameter  = $("#mparameter").val();//排序

                if(parameter.indexOf("=>")==-1){
                    layer.msg("请填写合法选项参数", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                var split = parameter.split("=>");
                if(split.length<=2&&(split[1]==''||split[0]=='')){
                    layer.msg("请填写合法选项参数", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }

                if(value == ''){
                    layer.msg("请填写默认值", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                if(parameter == ''){
                    layer.msg("请填写选择框参数", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                return $('#form').serialize()+'&value='+value+'&type='+tab_type+'&parameter='+parameter;
                break;
            case 'select':
                var value = $("input[name='select_value']").val();//排序
                var parameter  = $("#oparameter").val();//排序
                console.log(value)
                if(parameter.indexOf("=>")==-1){
                    layer.msg("请填写合法选项参数", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                var split = parameter.split("=>");
                if(split.length<=2&&(split[1]==''||split[0]=='')){
                    layer.msg("请填写合法选项参数", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }


                if(value == ''){
                    layer.msg("请填写默认值", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                if(parameter == ''){
                    layer.msg("请填写下拉框参数", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                return $('#form').serialize()+'&value='+value+'&type='+tab_type+'&parameter='+parameter;
                break;
            case 'upload':
                var upload_type = $("input[name='upload_type']:checked").val();//是否隐藏

                if(upload_type == ''){
                    layer.msg("请选择文件类型", {
                        icon : 2,
                        time : 1500
                    });
                    return false;
                }
                return $('#form').serialize()+'&type='+tab_type;
                break;
        }
        return false;
    }

    function getIndex(type) {
        var rs=0;
        switch(type) {
            case 'text':
                rs=0;
                break;
            case 'textarea':
                rs=1;
                break;
            case 'r_textarea':
                rs=2;
                break;
            case 'radio':
                rs=3;
                break;
            case 'checkbox':
                rs=4;
                break;
            case 'select':
                rs=5;
                break;
            case 'upload':
                rs=6;
                break;
        }
        return rs;
    }

    function getType(index) {
        var rs='text';
        switch(index) {
            case 0:
                rs='text';
                break;
            case 1:
                rs='textarea';
                break;
            case 2:
                rs='r_textarea';
                break;
            case 3:
                rs='radio';
                break;
            case 4:
                rs='checkbox';
                break;
            case 5:
                rs='select';
                break;
            case 6:
                rs='upload';
                break;
        }
        return rs;
    }

    /**
     * 富文本编码
     * @param text
     * @returns {string}
     */
    function r_text_encode(text)
    {
        return window.btoa(window.encodeURIComponent(text))
    }

</script>
{/block}